<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>转班申请</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
</head>
<body>
	<!-- 转班申请 -->
	<form id="ent" lay-filter="ent" class="layui-form layui-form-pane"
		style="margin: 0; pause: 5px 0 0 25px; color: #333;">
		<div class="layui-form-item" style="display: none">
			<div class="layui-inline">
				<label class="layui-form-label">所在班级ID</label>
				<div class="layui-input-inline">
					<input type="text" name="clazzId" readonly="readonly" value="${user.classInfo.clazz_id }"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item" style="display: none">
			<div class="layui-inline">
				<label class="layui-form-label">学生ID</label>
				<div class="layui-input-inline">
					<input type="text" name="stuId" readonly="readonly" value="${user.user_id }"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">姓名</label>
				<div class="layui-input-inline">
					<input type="text" name="userName" readonly="readonly" value="${user.user_name }"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">所在班级</label>
				<div class="layui-input-inline">
					<input type="text" name="clazzName" readonly="readonly" value="${user.classInfo.clazz_name }"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">想转入班级</label>
			<div class="layui-input-inline">
				<select name="likeClazz" lay-verify="required" lay-search="" id="likeClazz">
				</select>
			</div>
		</div>
		<!-- 按钮 -->
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn layui-btn-primary" id="zhuanban"
					>立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<!-- js引入 -->
	<script src="js/jquery.js"></script>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript">
	layui.use(['table','form','layedit', 'laydate'], function(){
		var table = layui.table;
		  var form = layui.form
		  ,layer = layui.layer
		  ,layedit = layui.layedit
		  ,laydate = layui.laydate;
			$.ajax({
				  url:"getClazzAll",
					type:"get",
					success:function(data){
						if(data){
							var jieguo=data.data;
							for (var i = 0; i < jieguo.length; i++) {
							    $("#likeClazz").append("<option value="+jieguo[i].clazz_id+">"+jieguo[i].clazz_name+"</option>");
							}
							form.render();
						}
					}
			  });
	});
	$(function(){
		$("#zhuanban").click(function(){
			var likeClazz=$("#likeClazz option:checked").val();
			var clazzId=$("input[name='clazzId']").val();
			var stuId=$("input[name='stuId']").val();
			if(likeClazz==clazzId){
				alert("你已在此班级,无法申请转入");
			}else{
				$.ajax({
					  url:"changeclazz",
						type:"post",
						data:{
							likeClazz:likeClazz,
							clazzId:clazzId,
							stuId:stuId
						},
						success:function(data){
							if(data=="1"){
								alert("已提交申请，请耐心等待处理结果");
								location.href="home";
							}else{
								alert("发生了未知错误导致失败");
							}
						}
				  });
			}
		});
	});
	</script>
</body>
</html>